package edu.hitsz.factory.enemyFactory;

import edu.hitsz.aircraft.enemy.AbstractEnemy;
import edu.hitsz.application.Game.Game;
import edu.hitsz.application.Main;

public abstract class EnemyFactory {
    int baseHp;
    int baseSpeedX;
    int baseSpeedY;

    int hp;
    int speedX;
    int speedY;

    public EnemyFactory() {
        setValue();
    }

    public void setValue(){
        setBaseValue();
        setModeValue();
        setLevelValue();
    }

    /**
     * 设置基础数值
     */
    public abstract void setBaseValue();

    /**
     * 根据游戏难度，设置数值
     */
    public abstract void setEasyMode();
    public abstract void setNormalMode();
    public abstract void setHardMode();

    public void setModeValue(){
        if(Main.gameMode==Main.EASY_MODE){
            setEasyMode();
        }else if(Main.gameMode==Main.NORMAL_MODE){
            setNormalMode();
        }else {
            setHardMode();
        }
    }

    /**
     * 根据游戏级别，设置数值
     */
    public void setLevelValue(){
        double rate= (double) (Game.gameLevel - 1) /10+1;
        hp= (int) (hp*rate);
        speedX=(int)(speedX*rate);
        speedY=(int)(speedY*rate);
    }


    /**
     * 策略模式，创建敌机对象
     * @return
     */
    public abstract AbstractEnemy createEnemy();
}
